<template>
    <view :style="themeColor" class="sunbathing-container">
		<tab-bar :tabs="tabs" :tabIndex="tabIndex" background="#fff" @clickTab="clickTab"/>
			<swiper
			    class="main"
			    :style="{ height: listHeight }"
			    :current="tabIndex"
			    @change="swiperChange">
			    <swiper-item v-for="(itemt, i) in tabs">
			       <list-content :state="itemt.state" :height="listHeight" :requestData="requestData"/>
			    </swiper-item>
			</swiper>
        <list-bottom />
    </view>
</template>

<script>
import tabBar from "@/components/common/tab-bar.vue"
import listContent from "./childCpns/list-content.vue"
import listBottom from "./childCpns/list-bottom.vue"
import { mapActions } from "vuex"
import { getElementHeight } from "@/uni-sub-base/utils/elementUtil.js"
import { getAccountBalance, GetUserLoginList, SwitchUserLogin,GetMemberGradeInfo} from "@/service/api/member.js"
export default {
    components: {
		tabBar,
        listContent,
        listBottom,
    },
    data() {
        return {
            pageNumber: 1,
            pageSize: 20,
			tabs: [
			    {
			        title: "待审核",
					state: "0",
			    },
			    {
			        title: "已审核",
					state: "1",
			    },
			    {
			        title: "已驳回",
					state: "2",
			    },
			],
			tabIndex: 0, // 当前tab的下标
			listHeight: 0,
			requestData: {
			    searchKey: "",
			    startTime: "",
			    endTime: "",
			},
			isloadding: false,
        }
    },
	mounted() {
		this.getListHeight()
		this.GetStoreId()
	},
    methods: {
        // 上拉加载
		getListHeight(element) {
		    //获取列表高度
		        getElementHeight(this, ".main", (e) => {
		            //再获取列表高度
		            this.listHeight = e - uni.upx2px(130) + "px"
		            this.load = true
		        })
		},
		GetStoreId(){
			GetMemberGradeInfo().then((rsp) => {
				if (rsp.State == 1 && rsp.Data) {
					if(!(rsp.Data.Name=='会员晒单' || rsp.Data.Name=='业务代理' || rsp.Data.Name=='超级会员' || rsp.Data.Name=='批发客户')){
						uni.showModal({
						    title: "提示",
						    content: '您没有操作权限',
						    showCancel: false,
							success: (res) => {
								if(res.confirm) {  
									uni.reLaunch({
									    url: "/pages/index/index",
									})
								} 
							}
						})
					}
				}
			})
		},
		swiperChange(e) {
		    this.tabIndex = e.detail.current
		    this.clickTab(this.tabIndex)
		},
		clickTab(index) {
		    if (this.tabIndex != index) {
		        this.tabIndex = index
		    }
		},
    },
}
</script>

<style lang="scss" scoped>
.sunbathing-container {
    height: calc(100vh - 88rpx);
    overflow: hidden;
}
</style>
